import { BasicColumn, FormSchema } from '/@/components/Table';
import { defaultRule } from '@/utils/common/validator';
import { userRemarkFormItem, userStatusFormItem } from '@/settings/ShareFormItem';
import { userRemarksColumn, userStatusColumn } from '@/settings/ShareTableColumns';
import metadata from '@/settings/metadata';

const typeOptions = [
  {
    label: '条形码',
    value: 0,
  },
  {
    label: '二维码',
    value: 1,
  },
];
export const useBarCodeUpdateSchemaForm = (): FormSchema[] => {
  return [
    { field: 'id', label: '', component: 'Input', show: false },
    { field: 'name', label: '条码名称', component: 'Input', rules: defaultRule() },
    { field: 'info', label: '条码内容', component: 'Input', required: true },
    {
      field: 'type',
      label: '条码类型',
      component: 'Select',
      componentProps: { options: typeOptions },
    },
    userStatusFormItem(),
    userRemarkFormItem(),
  ];
};

export const useBarCodeListColumns = (): BasicColumn[] => {
  return [
    { title: '条码名称', dataIndex: 'name' },
    { title: '条码内容', dataIndex: 'info' },
    { title: '条码类型', dataIndex: 'typeStr' },
    userStatusColumn(),
    userRemarksColumn(),
  ];
};

export const useBarCodeListSearchForm = (): FormSchema[] => {
  return [
    { field: 'name', label: '条形码名称', component: 'Input' },
    { field: 'info', label: '条形码信息', component: 'Input' },
    {
      field: 'type',
      label: '条形码类型',
      component: 'Select',
      componentProps: { options: typeOptions },
    },
    {
      field: 'status',
      label: '状态',
      component: 'Select',
      componentProps: { options: metadata.userStatusData },
    },
  ];
};
